package com.jtfr.core;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 初始化SimpleMybatis框架
 * @author ckm
 *
 */
public class SqlSessionFactory {
	
	private static Logger LOGGER = LoggerFactory.getLogger(SqlSessionFactory.class);

    static {
    	// 初始化SqlMappersHolder
        MapperHandler.getSqlMapperHolder();
        try {
        	// 加载驱动
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
        	LOGGER.error("加载 mysql 驱动失败", e);
        	throw new RuntimeException("加载 mysql 驱动失败", e);
        }
    }

    /**
     * 
     * 返回一个代理对象
     * @return
     */
    public SqlSession openSession() {
        return new SqlSession();
    }
}
